package com.lm.controller;


import com.lm.model.auto.Classify;
import com.lm.model.auto.Infor;
import com.lm.service.IClassifyService;
import com.lm.service.InforService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 达瓦里氏
 * @since 2021-12-10
 */
@RestController
@RequestMapping("/classify")
@CrossOrigin
public class ClassifyController {

    @Resource
    private IClassifyService iClassifyService;

    /*查询类别*/
    @GetMapping("/getClassify")
    public List<Classify> getClassify(){ return iClassifyService.list(); }

    /*通过id查询类别*/
    @GetMapping("/getClassifyById/{id}")
    public Classify getClassifyById(@PathVariable("id") int id){
        return iClassifyService.getById(id);
    }

    /*修改类别*/
    @PostMapping("/updateClassify")
    public void updateClassify(@RequestBody Classify classify){ iClassifyService.updateById(classify); }

    /*添加类别*/
    @PostMapping("/setClassify")
    public void setClassify(@RequestBody Classify classify){ iClassifyService.save(classify); }

    /*删除类别*/
    @PostMapping("/deletedById/{id}")
    public boolean deleted(@PathVariable("id") int id){ return iClassifyService.removeById(id); }

}
